<?php
require_once 'dal/ConnectionFactory.php';
require_once 'dal/PersonDao.php';

$testperson = array(
		"postcode" => 10001,
		"personid" => NULL,	# forces auto generate
		"username" => "test_user",
		"salutation" => "Frau",
		"firstname" => "Captain",
		"lastname" => "Debug",
		"email" => "teh.captain@test.de",
		"born" => "2008-02-05",
		"street" => "Teststrasse 1",
		"licencenr" => "666",
		"licencesince" => "2009-04-02",
		"ccnr" => NULL,
		"iban" => 23647540368549038,
		"bic" => 12487352,
		"premium" => 1,
		"pwhash" => "test_pw",
		"salt" => "test_salt",
		);
print "PersonDao Test run\nUsing test person :\n";
print_r($testperson);
print "Connecting...\n";
$dbh = ConnectionFactory::getInstance()->open();
$dao = new PersonDao($dbh);
print "Saving...\n";
$newId = $dao->save($testperson);
print "Saved with id ".$newId."\n";
print "Fetching...\n";
$fetched = $dao->findById($newId);
print "Fetched :\n";
print_r($fetched);
print "Deleting :\n";
$dao->delete($newId);
print "Deleted\n";
$dao->dispose();
echo "Done";
?>